package com.keyinong.parkin.mall.adapter;

import java.util.ArrayList;
import java.util.HashMap;

import com.example.parkin.R;
import com.keyinong.parkin.home.bean.AddressBean;
import com.keyinong.parkin.home.bean.ParkinBean;
import com.keyinong.parkin.mall.bean.MallTypeBean;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class SelectMallTypeAdapter extends BaseAdapter {
	Context context;
	ArrayList<MallTypeBean> list;
	int isindex = 0;

	public SelectMallTypeAdapter(Context context,
			ArrayList<MallTypeBean> list) {
		super();
		this.context = context;
		this.list = list;
	}

	public void setindex(int isindex) {
		this.isindex = isindex;
	}

	@Override
	public int getCount() {

		return list.size();
	}

	@Override
	public Object getItem(int position) {

		return list.get(position);
	}

	@Override
	public long getItemId(int position) {

		return 0;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		ViewHandle handle = null;
		if (view == null) {
			handle = new ViewHandle();
			view = LayoutInflater.from(context).inflate(
					R.layout.item_list_malltype, null);
			handle.tv_mallType = (TextView) view.findViewById(R.id.tv_mallType);
			view.setTag(handle);
		} else {
			handle = (ViewHandle) view.getTag();
			
		}
		if(isindex == position){
			handle.tv_mallType.setTextColor(context.getResources().getColor(
					R.color.homeBlue));
//			handle.tv_mallType.setBackgroundColor(context.getResources().getColor(
//					R.color.white));
			handle.tv_mallType.setBackgroundResource(R.drawable.shape_nomallsort);
		}else{
			handle.tv_mallType.setTextColor(context.getResources().getColor(
					R.color.notice));
			handle.tv_mallType.setBackgroundResource(R.drawable.shape_mallsort);
			
		}
		handle.tv_mallType.setText(list.get(position).getName());

		return view;
	}

	private class ViewHandle {
		TextView tv_mallType;
	}
}
